package com.zxd.date;

/**
 * ClassName:MyPeriod
 * Package:com.zxd.newdate
 *
 * @Date:2023/9/18 22:13
 * @Author:zxde
 */

import java.time.LocalDate;
import java.time.Period;

/**
 * 计算相差的月数
 * 1999.11.14 与  2023.9.18
 * 间隔23年10月4天
 */
public class MyPeriod {
    public static void main(String[] args) {
        LocalDate ld1 = LocalDate.of(1999, 11, 14);
        LocalDate ld2 = LocalDate.of(2023, 9, 18);
        Period between = Period.between(ld1, ld2);
        System.out.print("间隔："+between.getYears()+"年");
        System.out.print(between.getMonths()+"月");
        System.out.println(between.getDays()+"天");
    }
}
